#encoding:utf8

import os
import time

from lib import *



def printlog(text):
	try:
		flog(text)
		print(text)
	except UnicodeEncodeError as ex:
		pass


def scanserver(remotename):
	movieExts		= set(('.avi', '.mkv', '.mp4', '.mpeg', '.mpg', '.rm', '.rmvb', '.wmv'))
	minMovieSize	= 30000000
	
	daySpan			= 7
	daySpan			= time.time() - daySpan * 24 * 60 * 60


	print '------process server:', remotename 

	for root, dirs, files in os.walk(remotename):
		for name in files:
			ext		   = os.path.splitext(name)
			if not ext[1].lower() in movieExts:
				continue

			path			= os.path.join(root, name)
			printlog(path)

def main():
	servers		= {ur'\\10.12.0.10': [u'Public'], ur'\\10.12.0.110': [u'Public', u'电影&音乐'], ur'\\10.12.0.111' : [u'多媒体资源', u'Public', u'media(zbr)'] }
	for ip, folders in servers.items():
		for folder in folders:
			remotename	= '%s\\%s'%(ip, folder)
			scanserver(remotename)

if __name__=='__main__':
	main()
